package org.openeccos.dao;

import java.util.Calendar;

import org.openeccos.model.MBase;
import org.openeccos.model.MTask;
import org.openeccos.model.MUser;

import com.sas.framework.expojo.PersistenceProvider;
import com.sas.framework.expojo.ServiceComponent;

public class EccosService extends ServiceComponent {

	public static final String NAME = "EccosService";
	
	public String getName() {
		return NAME;
	}

	public void closeTask(MTask task, MUser currentUser) {
		task.setDoneDate(Calendar.getInstance().getTime());
		task.setDoneBy(currentUser);
		persist(task);
	}
	
	public MUser createNewUser(String username, String password) {
		PersistenceProvider pp = modelExposer.getPersistenceProvider();
		MUser user = new MUser();
		user.setLogin(username);
		pp.persist(user);
		return user;
	}

	public void delete(Object m) {
		PersistenceProvider pp = modelExposer.getPersistenceProvider();
		pp.delete(m);
	}
	
	public void persist(Object m) {
		PersistenceProvider pp = modelExposer.getPersistenceProvider();
		pp.persist(m);
	}
}
